<template>
  <div class="app-container video">
    <span class="title">全部视频({{total}})</span>
    <div class="container-flex book">
      <div class="block" v-for="(item,index) in list" :key="index" @click="goToInfo(item)">
        <div class="book-item">
          <span v-if="item.cover" class="book-cover" :style="{backgroundImage:'url('+item.cover+')'}">
          </span>
          <span v-else class="book-cover" style="backgroundImage:'url('../../../static/images/base/video-box.png')'">
          </span>
          <span class="book-name" v-html="item.name">李宇春压轴登场 小小鹿小小鹿</span>
        </div>
      </div>
    </div>
    <div class="pagination">
      <el-pagination @current-change="handleCurrentChange" :current-page.sync="currentPage" :page-size="pageSize" layout="total, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>
    <hr>
    <!-- <span class="title">全部音频(10)</span>
        <div class="container-flex music">
            <div class="block" v-for="(item,index) in 10" :key="index">
                <div class="music-item">
                    <span class="music-cover">
                        <img src="/static/images/base/music.png" alt="">
                    </span>
                    <span class="music-name">晓说2018</span>
                </div>
            </div>
        </div>
        <div class="pagination">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="currentPage" :page-size="100" layout="prev, pager, next, jumper" :total="1000">
            </el-pagination>
        </div> -->
  </div>
</template>

<script>
import { myCollect } from "@/api/index";
export default {
  data() {
    return {
      currentPage: 1,
      list: [],
      total: 0,
      pageSize: 16
    };
  },
  components: {},
  created() {
    this.init();
  },
  watch: {
    $route() {
      this.currentPage = Number(this.$route.query.currentPage) || 1;
      this.init(this.currentPage);
    }
  },
  methods: {
    init(pageNo) {
      myCollect(7, pageNo, this.pageSize).then(res => {
        console.log(res.data.date.list);
        this.total = res.data.date.total;
        this.list = res.data.date.list;
      });
    },
    goToInfo(item) {
      this.$router.push({
        path: "/record_videocontent",
        query: {
          item: JSON.stringify(item)
        }
      });
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.$router.push(this.$route.path + "?currentPage=" + this.currentPage);
    }
  }
};
</script>
<style lang="less" scoped>
.video {
  .title {
    font-size: 20px;
    display: block;
    margin: 13px 0px 28px 0px;
  }
  .book {
    flex-wrap: wrap;
    justify-content: flex-start;
    .block {
      margin-left: 38px;
      width: 184px;
      cursor: pointer;
      .book-cover {
        background: url("/static/images/base/video-box.png");
        background-size: cover;
        width: 184px;
        height: 106px;
        display: block;
        position: relative;
        border-radius: 10px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
        img {
          position: absolute;
          right: 20px;
          bottom: 10px;
        }
      }
      .book-name {
        margin-top: 8px;
        margin-bottom: 24px;
        display: block;
        font-size: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: center;
      }
    }
    .block:nth-child(4n + 1) {
      margin-left: 0px;
    }
  }
  .music {
    flex-wrap: wrap;
    justify-content: flex-start;
    .block {
      margin-left: 46px;
      width: 178px;
      .music-cover {
        background: url("/static/images/base/muisc-box.png") no-repeat;
        background-size: cover;
        width: 178px;
        height: 148px;
        display: block;
        position: relative;
        border-radius: 10px;
        img {
          position: absolute;
          right: 20px;
          bottom: 10px;
        }
      }
      .music-name {
        margin-top: 8px;
        margin-bottom: 24px;
        display: block;
        font-size: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: center;
      }
    }
    .block:nth-child(4n + 1) {
      margin-left: 0px;
    }
  }
}
</style>

